

	/* Replicate analysis from Arzheimer/Evans IJF article */
	set matsize 800
use replication,clear


	set more off

	capture drop ptr*


  /*Full Models + Fixed Effect Only Models*/
  /* _x_* are the dummies (deviations) for 95 departements*/

  /*Non-Communist Left*/
  
	reg trleft unempfr incleft incleftXunempfr natgrowth  _x* if year <2007
/* 	vif */
	est store left
	predict ptrleft
	qui 	reg trleft  _x* if year <2007
	est store dleft

/*Non-Extreme Right*/

	reg trright unempfr incleft  incleftXunempfr natgrowth _x* if year <2007 
/* 	vif */
	est store right
	predict ptrright
	qui 	reg trright _x* if year <2007 
	est store dright


/*Communists*/

	reg trkommunist unempfr incleft incleftXunempfr natgrowth _x* if year <2007 
/* 	vif */
	est store kommunist
	predict ptrkomm
	qui reg trkommunist  _x* if year <2007
	est store dkommunist
	
	
/*FN*/

	reg trfn  unempfr incleft incleftXunempfr natgrowth _x* if year <2007 
/* 	vif */
	est store fn
	predict ptrfn
	qui reg trfn  _x* if year <2007
	est store dfn


/*All other choices*/

	reg trrest unempfr incleft incleftXunempfr natgrowth _x* if year<2007
/* 	vif */
	est store rest
	predict ptrrest
	qui 	reg trrest _x* if year<2007
	est store drest

/*Combine individual estimates to get SUR ses*/

	suest left right kommunist fn rest,cluster(adm)

est store sur

/*Save full model*/

/*This gives you *lots* of fixed effects*/

  /*Reverse logit transformation to get predicted results for departments*/

  	capture drop exp*
	
	foreach v of varlist pt* {
		gen exp`v' = exp(`v')
		}

	capture drop divisor

	capture drop pr*
	
	egen divisor = rowtotal(expptrleft - expptrrest)
	replace divisor = divisor + 1
	gen prnonv = 100 / divisor

	
	
	foreach v in left right komm fn rest {
		gen pr`v' = (expptr`v' * 100) / divisor
		}



/*Create a table for 2007 predictions*/
  	summ left if year ==2007
	matrix temp = r(mean)
	summ prleft if year ==2007
	matrix temp = temp, r(mean)

	matrix pr2007 = temp

	summ right if year ==2007
	matrix temp = r(mean)
	summ prright if year ==2007
	matrix temp = temp, r(mean)

	matrix pr2007 = pr2007 \temp

	summ komm if year ==2007
	matrix temp = r(mean)
	summ prkomm if year ==2007
	matrix temp = temp, r(mean)

	matrix pr2007 = pr2007 \temp

	summ fn if year ==2007
	matrix temp = r(mean)
	summ prfn if year ==2007
	matrix temp = temp, r(mean)

	matrix pr2007 = pr2007 \temp


	summ rest if year ==2007
	matrix temp = r(mean)
	summ prrest if year ==2007
	matrix temp = temp, r(mean)

	matrix pr2007 = pr2007 \temp

	summ nonv if year ==2007
	matrix temp = r(mean)
	summ prnonv if year ==2007
	matrix temp = temp, r(mean)

	matrix pr2007 = pr2007 \temp

	capture drop party
	
	gen party = " "
	replace party = "Mod Left" in 1
	replace party = "Mod Right" in 2
	replace party = "Communists" in 3
	replace party = "Extreme Right" in 4
	replace party = "Other" in 5
	replace party = "Nonvoters" in 6
	

	capture drop observed
	capture drop predicted
	svmat pr2007

	format %9.1f pr2007*
	rename pr20071 observed
	rename pr20072 predicted
	
	list party observed predicted in 1/6,sep(0)

/*Compare model stats (Table 1)*/
  est stat dleft left dright right dkommunist kommunist dfn fn drest rest

